<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>粘性定位</title>
    <style>
        body{height: 2000px;}
        header{
            width: 100%;
            height: 100px;
            background: red;
            line-height: 100px;
            text-align: center;
            position: sticky;
            left: 0px;
            top: 0px;
        }
        .center{
            width: 100%;
            height: 100px;
            background: blue;
            position: sticky;
            left: 0px;
            top: 0px;
            margin-top: 500px;
        }
    </style>
</head>
<body>
    <p>position：sticky</p>
    <p>以浏览器的可视窗口来移动元素</p>
    <p>占有原先的位置</p>
    <p>必须添加top，bottom，left，right才有效</p>

    <header>
        sticky
    </header>

    <div class="center">

    </div>


</body>
</html>